package com.jzy.bxb.model.mongo.dao;

import org.mongodb.morphia.Morphia;
import org.mongodb.morphia.dao.BasicDAO;

import com.jzy.bxb.core.db.mongo.AbsMongoManager;
import com.jzy.bxb.model.mongo.entity.config.ConfigProvince;
import com.mongodb.MongoClient;

/**
 * 省市区
 * 
 * @author JiangZhiYong
 *
 */
public class ConfigProvinceDao extends BasicDAO<ConfigProvince, String> {

	private static volatile ConfigProvinceDao configProvinceDao;

	public ConfigProvinceDao(AbsMongoManager mongoManager) {
		super(ConfigProvince.class, mongoManager.getMongoClient(), mongoManager
				.getMorphia(), mongoManager.getMongoConfig().getDbName());
	}

	public ConfigProvinceDao(Class<ConfigProvince> entityClass,
			MongoClient mongoClient, Morphia morphia, String dbName) {
		super(entityClass, mongoClient, morphia, dbName);
	}

	public static ConfigProvinceDao init(AbsMongoManager mongoManager) {
		if (configProvinceDao == null) {
			synchronized (UserDao.class) {
				if (configProvinceDao == null) {
					configProvinceDao = new ConfigProvinceDao(mongoManager);
				}
			}
		}
		return configProvinceDao;
	}

	public static void saveConfigProvince(ConfigProvince configProvince) {
		configProvinceDao.save(configProvince);
	}
}
